const express = require("express");

const tools = require("../../model/tools");

var router = express.Router()

router.get("/", (req, res) => {
    res.send("用户列表");
})

router.get("/add", (req, res) => {
    res.render("admin/user/add", { title: "添加用户" });
});

const uploadMiddleware = tools.multer().fields([
    { name: "pic1", maxCount: 1 },
    { name: "pic2", maxCount: 1 }
])

router.post("/doAdd", uploadMiddleware,(req, res) => {
    res.send({
        body: req.body, // 获取post传值
        files: req.files // 获取上传的文件信息
    });
    // 注意：如果使用了body-parser中间件，req.body可以直接获取post
})

module.exports = router